<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue-父子组件</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>

<body>
    <div id="app">
        <h3>父子组件</h3>
        <parent></parent>

    </div>
    <script>
        let Child1 = Vue.extend({
            template: `
            <div>我是子组件one</div>
          `
        });
        let Child2 = Vue.extend({
            template: `
            <div>我是子组件two</div>
          `

        });
        Vue.component('parent', {
            components: {
                "child1": Child1,
                "child2": Child2
            },
            template: `
            <div style="background: skyblue">
              我是父组件
              <div style="color: white">
                <child1></child1>
                <child2></child2>
              </div>              
            </div>
            `
        })
        new Vue({
            el: '#app',

        });
    </script>
</body>

</html>